NodeMCU
Pin Configuration of NodeMCU
#include<ESP8266WiFi.h> #include<ESP8266WebServer.h> ESP8266WebServer server; //====================================== //HTML DEVICE CONTROL PAGESOURCE CODE //======================================= const char MAIN_Page[]PROGMEM = R"======( <html> <head> <title>Gemicates</title> </head> <body> <center> <h1>NodeMCU Webserver</h1> </center> <h4>Synopsis</h4> <p>In this experiment, we will learn how to make your NodeMCU Board as an Access Point (AP-Mode) with Arduino Coding. This ESP8266 board will act as Wireless Router and the devices can connect the NodeMCU. </p> <p>This mode will help to create a Local Area Network between the devices it can’t push and pull the data from the cloud the Communication happens between the locally connected devices only. </p> <h4>Description</h4> ESP8266 NodeMCU V1.0 Board featured with the 2 Modes: 1. Access Point Mode (Board will act as Hotspot) 2. Station Mode (Board will act as a client to the Router) This board consists of enough flash memory (4MB) to store the Simple Webpages and clients will access those pages through their browsers by running the Webserver at firmware Level, with the help of a web interface, you can control the devices and monitor the sensor values in which we are connected to the NodeMCU board. <h4>Hardware Needed</h4> <ol> <li>NodeMCU Board</li> <li>USB A to Micro USB Cable</li> <li>Wi-Fi Enabled Devices like Mobile, Laptop, etc...</li> </ol> <h4>Software Needed</h4> <ol> <li>Arduino IDE</li> </ol> <h4>Procedure</h4> <ol> <li>Set the SSID (Wi-Fi-Name) and Password in the code which you preferred </li> <li>Upload the Code into the NodeMCU through your Arduino IDE by selecting respective board models.</li> <li>You can connect to your NodeMCU Hotspot with the proper credentials mentioned in the code.</li> </ol> </body> </html> )======"; //====================================== //SETUP FUNCTION //======================================= void setup() { Serial.begin(9600); Serial.print("Enabling the Hotspot in NodeMCU.."); boolean HOTSPOT = WiFi.softAP("NODEMCU-AP", "12345678"); if(HOTSPOT == true) { Serial.println("HOTSPOT IS READY"); } else { Serial.println("Failed! to Switch the Hotspot"); } Serial.print("ACCESS POINT IP address: "); Serial.println(WiFi.softAPIP()); Serial.print("LOCAL IP address: "); Serial.println(WiFi.localIP()); server.on("/", Homepage); server.begin(); } //====================================== //LOOP FUNCTION //======================================= void loop() { server.handleClient(); } //====================================== //HOME PAGE //======================================= void Homepage() { String s = MAIN_Page;//read html content server.send(200,"text/html",s);//send web page }